<template>
    <div :style="{ opacity }">
        <custom-nav-bar :text="'健康综合分析'" :bgColor="'#F0F3F7'" :frontColor="'#432F37'" :isFixed="true" />
    </div>
    <div class="page">
        <div class="top">
            <div class="top-card">
                <custom-nav-bar :text="'健康综合分析'" :bgColor="'tansparent'" :frontColor="'#ffffff'" :isFixed="false"
                    isPlaceholder />
                <div class="card">
                    <div class="row">
                        <div class="col1">
                            <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/health_icon_1.png" class="icon1" />
                            <div class="text">综合活力指数:</div>
                        </div>
                        <div class="col2">{{ healthData.conclusion }}</div>
                    </div>
                    <div class="row2">
                        <div class="text">{{healthData.score}}</div>
                        <div class="col" v-if="healthData.scoreChange">
                            <image v-if="healthData.scoreChange > 0" src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/health_icon_2.png" class="icon2" />
                            <image v-if="healthData.scoreChange < 0" src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/health_icon_22.png" class="icon2" />
                            <div class="add">{{healthData.scoreChange === 0 ? '无变化' : healthData.scoreChange}}</div>
                        </div>
                        <div class="col" v-else>
                            <div class="add">无变化</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="charts">
            <div class="title">
                <div class="text">
                    综合分析
                </div>                    
                <div class="right-text">
                    <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/health_icon_3.png" class="icon" />
                    极坐标
                </div>
            </div>
            <div class="chart-box">
                <RadarEchart :reportData="healthData" />
            </div>
        </div>
        <div class="base-health-analysis" @click="navTo('baseHealthy')">
            <div class="base_title">
                <div class="base_title_text">基础健康分析</div>
                <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/healthy-arrow.png" class="base_icon" />
            </div>
            <div class="base_top">
              <div class="num">{{ healthData.ovBasicHealth.score }}</div>
              <div class="text">{{healthData.ovBasicHealth.conclusion}}</div>
              <div class="process">
                <div class="process-bar">
                    <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/healthy-ad.png" class="process-bar-ad" :style="{opacity: healthData.ovBasicHealth.conclusionLevel == 1 ? 1 : 0}"/>
                    <div class="process-bar-fill" style="background: #DE4C2B;"></div>
                </div>
                <div class="process-bar">
                    <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/healthy-ad.png" class="process-bar-ad" :style="{opacity: healthData.ovBasicHealth.conclusionLevel == 2 ? 1 : 0}"/>
                    <div class="process-bar-fill" style="background: #F2A133;"></div>
                </div>
                <div class="process-bar">
                    <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/healthy-ad.png" class="process-bar-ad" :style="{opacity: healthData.ovBasicHealth.conclusionLevel == 3 ? 1 : 0}"/>
                    <div class="process-bar-fill" style="background: #ABCD32;"></div>
                </div>
              </div>
            </div>
            <div class="base_bottom">
                <div class="item">
                    <div class="item-title">
                        体重 (kg)
                    </div>
                    <div class="item-value">{{healthData.weight}}</div>
                </div>
                <div class="item">
                    <div class="item-title">
                        骨骼肌 (kg)
                    </div>
                    <div class="item-value">{{healthData.smm}}</div>
                </div>
                <div class="item">
                    <div class="item-title">
                        体脂率 (%)
                    </div>
                    <div class="item-value">{{healthData.pbf}}</div>
                </div>
            </div>
        </div>
        <div class="shape_box" >
            <div class="box-item" @click="navTo('shape')">
                <div class="box_item_title">
                    <div class="box_item_title_text">体态与功能性</div>
                    <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/healthy-arrow.png" class="title_icon" />
                </div>
                <div class="value_box">
                    <div class="value_box_num">{{healthData.ovHealthAssessment.score}}</div>
                    <div class="value_box_text">{{healthData.ovHealthAssessment.conclusion}}</div>
                </div>
                <div class="pic-box">
                    <image :src="healthData.frontImg" class="front_pic" />
                </div>
            </div>
            <div class="box-item" @click="navTo('sport-ability')">
                <div class="box_item_title">
                    <div class="box_item_title_text">运动能力与耐力</div>
                    <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/healthy-arrow.png" class="title_icon" />
                </div>
                <div class="value_box">
                    <div class="value_box_num">{{healthData.ovSportAbility.score}}</div>
                    <div class="value_box_text">{{healthData.ovSportAbility.conclusion}}</div>
                </div>
                <div class="pic2-box">
                    <div class="p">
                        <div class="name">右握力 (kg)</div>
                        <div class="value">{{healthData.handStrength.right}}</div>                        
                    </div>
                    <div class="p">
                        <div class="name">......</div>
                    </div>
                    <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/healthy-icon_4.png" class="pic2" />
                </div>
            </div>
        </div>
        <div class="sport_safe" @click="navTo('sport-safe')">
            <div class="sport_safe_title">
                <div class="sport_safe_title_text">运动安全与适应性</div>
                <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/healthy-arrow.png" class="title_icon" />
            </div>
            <div class="sport_safe_content">
                <div class="sport_safe_content_value_box">
                    <div class="sport_safe_content_value_box_num">{{healthData.ovSportRisk.score}}</div>
                    <div class="sport_safe_content_value_box_text">{{healthData.ovSportRisk.conclusion}}</div>
                </div>
                <div class="sport_safe_content_pic_box">
                    <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/healthy-icon_5.png" class="sport_safe_pic" />
                </div>
            </div>
            <div class="sport_safe_content_bottom">
                <div class="sport_safe_content_bottom_item">
                    <div class="name">血压 (mmHg)</div>
                    <div class="value">{{healthData.pressure}}</div>
                </div>
                <div class="sport_safe_content_bottom_item">
                    <div class="name">静息心率 (次/分钟)</div>
                    <div class="value">{{healthData.staticHr}}</div>
                </div>
                <div class="sport_safe_content_bottom_item">
                    <div class="name">......</div>
                </div>
            </div>
        </div>
        <div class="social_health" @click="navTo('socal')">
            <div class="social_health_title">
                <div class="social_health_title_text">心理与社会活力</div>
                <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/healthy-arrow.png" class="title_icon" />
            </div>
            <div class="social_health_content">
                <div class="social_health_content_item">
                    <div class="name">{{healthData.ovSocialAbility.score}}</div>
                    <div class="text">{{healthData.ovSocialAbility.conclusion}}</div>
                </div>
            </div>
            <image src="https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/static/healthy-icon_6.png" class="social_health_content_item_pic" />
        </div>
    </div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import RadarEchart from './radar-echart.vue';

const props = defineProps({
    opacity: {
        type: String,
        default: '0'
    },
    healthData: {
        type: Object,
        default: () => ({})
    },
})
const navTo = (path: string) => {
    if(path === 'baseHealthy'){
        uni.navigateTo({
            url: `/subPackages_1/healthy-report/base-healthy` + `?testDataId=${props.healthData.testDataId}`
        })
    }
    if(path === 'shape'){
        uni.navigateTo({
            url: `/subPackages_1/healthy-report/shape` + `?testDataId=${props.healthData.testDataId}`
        })
    }
    if(path === 'sport-ability'){
        uni.navigateTo({
            url: `/subPackages_1/healthy-report/sport-ability` + `?testDataId=${props.healthData.testDataId}`
        })
    }
    if(path === 'socal'){
        uni.navigateTo({
            url: `/subPackages_1/healthy-report/socal` + `?testDataId=${props.healthData.testDataId}`
        })
    }
    if(path === 'sport-safe'){
        uni.navigateTo({
            url: `/subPackages_1/healthy-report/sport-safe` + `?testDataId=${props.healthData.testDataId}`
        })
    }
}
</script>
<style scoped lang="scss">
.page {
    padding-bottom: 200rpx;
    overflow-x: hidden;
    .top {
        width: 100%;
        height: 516rpx;
        background-image: url('https://andy-res.oss-cn-chengdu.aliyuncs.com/meyka-miniapp/common/healthy_top_bg.png');
        background-size: 100% 100%;
        background-repeat: no-repeat;

        .top-card {
            width: 100%;
            position: relative;
            padding-left: 24rpx;
            padding-right: 24rpx;
            box-sizing: border-box;

            .card {
                width: 462rpx;
                margin: 0 auto;
                margin-top: 36rpx;
                margin-right: 0;
                background: #FFFFFF;
                border-radius: 40rpx;
                padding: 32rpx;
                box-sizing: border-box;

                .row {
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    padding-bottom: 28rpx;
                    border-bottom: 4rpx dashed #E5E5E5;
                    box-sizing: border-box;

                    .col1 {
                        display: flex;
                        align-items: center;

                        .text {
                            font-weight: 600;
                            font-size: 32rpx;
                            color: #333333;
                            line-height: 44rpx;
                            margin-left: 6rpx;
                        }

                        .icon1 {
                            width: 32rpx;
                            height: 32rpx;
                        }
                    }

                    .col2 {
                        display: flex;
                        align-items: center;
                    }

                }

                .row2 {
                    display: flex;
                    align-items: center;
                    padding-top: 22rpx;
                    justify-content: center;
                    box-sizing: border-box;

                    .text {
                        font-weight: 600;
                        font-size: 72rpx;
                        color: #333333;
                        line-height: 100rpx;
                    }

                    .col {
                        display: flex;
                        align-items: center;

                        .icon2 {
                            width: 60rpx;
                            height: 60rpx;
                        }

                        .add {
                            font-weight: 600;
                            font-size: 60rpx;
                            color: #ABCD32;
                            line-height: 84rpx;
                        }
                    }
                }
            }
        }
    }

    .charts {
        position: relative;
        z-index: -1;
        width: 702rpx;
        background: #FFFFFF;
        margin: 0 auto;
        margin-top: -24rpx;
        border-radius: 0rpx 0rpx 40rpx 40rpx;
        padding: 52rpx 32rpx 0 32rpx;
        box-sizing: border-box;

        .title {
            display: flex;
            align-items: center;
            justify-content: space-between;
            .text{
                font-weight: 600;
                font-size: 32rpx;
                color: #333333;
                line-height: 44rpx  ;
            }
            .right-text{
                display: flex;
                align-items: center;
                font-weight: 400;
                font-size: 28rpx;
                color: #333333;
                line-height: 40rpx;
                .icon{
                    width: 30rpx;
                    height: 8rpx;
                    margin-right: 12rpx;
                }
            }
        }
    }
    .base-health-analysis{
        width: 702rpx;
        margin: 0 auto;
        margin-top: 36rpx;
        padding: 28rpx 32rpx;
        box-sizing: border-box;
        background: #FFFFFF;
        border-radius: 40rpx;
        .base_title{
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding-bottom: 26rpx;
            box-sizing: border-box;
            .base_title_text{
                font-weight: 600;
                font-size: 32rpx;
                color: #333333;
                line-height: 40rpx;
            }
            .base_icon{
                width: 48rpx;
                height: 48rpx;
            }
        }
        .base_top{
            display: flex;
            align-items: center;
            padding-bottom: 14rpx;
            border-bottom: 4rpx dashed #E5E5E5;
            .num{
                font-weight: 600;
                font-size: 48rpx;
                color: #999999;
                line-height: 66rpx;
                margin-right: 20rpx;
            }
            .text{
                font-weight: 600;
                font-size: 40rpx;
                color: #ABCD32;
                line-height: 56rpx;
                margin-right: 80rpx;
            }
            .process{
                display: flex;
                align-items: center;
                .process-bar{
                    text-align: center;
                    margin-right: 8rpx;
                    .process-bar-ad{
                        width: 32rpx;
                        height: 32rpx;
                    }
                    .process-bar-fill{
                        width: 100rpx;
                        height: 12rpx;
                        border-radius: 8rpx;
                    }
                    
                }
            }            
        }
        .base_bottom{
                width: 100%;
                padding-top: 20rpx;
                box-sizing: border-box;
                display: flex;
                align-items: center;
                justify-content: space-between;
                .item{
                    display: flex;
                    .item-title{
                        font-weight: 400;
                        font-size: 24rpx;
                        color: #999999;
                        line-height: 40rpx;
                        margin-right: 16rpx;
                    }
                    .item-value{
                        font-weight: 600;
                        font-size: 32rpx;
                        color: #333333;
                        line-height: 40rpx;
                    }
                }
            }
    }
    .shape_box{
        display: flex;
        justify-content: space-between;
        margin-top: 36rpx;
        padding: 0 24rpx;
        box-sizing: border-box;
        .box-item{
            width: 340rpx;
            background: #FFFFFF;
            border-radius: 40rpx;
            padding: 28rpx 32rpx;
            box-sizing: border-box;
            .box_item_title{
                display: flex;
                align-items: center;
                .box_item_title_text{
                    font-weight: 600;
                    font-size: 32rpx;
                    color: #333333;
                    line-height: 40rpx;
                }
                .title_icon{
                    width: 48rpx;
                    height: 48rpx;
                }
            }
            .value_box{
                display: flex;
                align-items: center;
                justify-content: space-between;
                padding-top: 26rpx;
                padding-bottom: 16rpx;
                box-sizing: border-box;
                border-bottom: 4rpx dashed #E5E5E5;
                .value_box_num{
                    font-weight: 600;
                    font-size: 48rpx;
                    color: #999999;
                    line-height: 66rpx;
                }
                .value_box_text{
                    font-weight: 600;
                    font-size: 40rpx;
                    color: #ABCD32;
                    line-height: 56rpx;
                }
            }
            .pic-box{                
                margin-top: 26rpx;
                .front_pic{
                    display: block;
                    width: 140rpx;
                    height: 280rpx;
                    margin: 0 auto;
                }
            }
            .pic2-box{
                margin-top: 26rpx;
                .p{
                    display: flex;
                    align-items: center;
                   .name{
                    font-family: PingFangSC, PingFang SC;
                    font-weight: 400;
                    font-size: 24rpx;
                    color: #999999;
                    line-height: 40rpx;
                    text-align: left;
                   }
                   .value{
                        font-family: PingFangSC, PingFang SC;
                        font-weight: 600;
                        font-size: 32rpx;
                        color: #333333;
                        line-height: 40rpx;
                        text-align: left;
                   }
                }
                .pic2{
                    display: block;
                    width: 160rpx;
                    height: 160rpx;
                    margin: 0 auto;
                    margin-right: 0;
                }
            }
        }
    }
    .sport_safe{
        width: 702rpx;
        margin: 0 auto;
        margin-top: 36rpx;
        background: #FFFFFF;
        border-radius: 40rpx;
        padding:28rpx 32rpx;
        box-sizing: border-box;
        .sport_safe_title{
            display: flex;
            align-items: center;
            justify-content: space-between;
            .sport_safe_title_text{
                font-weight: 600;
                font-size: 32rpx;
                color: #333333;
                line-height: 40rpx;
            }
            .title_icon{
                width: 48rpx;
                height: 48rpx;
            }
        }
        .sport_safe_content{
            display: flex;
            align-items: center;
            padding-bottom: 10rpx;
            padding-top: 26rpx;
            border-bottom: 4rpx dashed #E5E5E5;
            box-sizing: border-box;
            .sport_safe_content_value_box{
                display: flex;
                align-items: center;
                justify-content: space-between;
                .sport_safe_content_value_box_num{
                    font-weight: 600;
                    font-size: 48rpx;
                    color: #999999;
                    line-height: 66rpx;
                    margin-right: 20rpx;
                }
                .sport_safe_content_value_box_text{
                    font-weight: 600;
                    font-size: 40rpx;
                    color: #F2A133;
                    line-height: 56rpx;
                    margin-right: 80rpx;
                }
            }
            .sport_safe_content_pic_box{
                .sport_safe_pic{
                    width: 318rpx;
                    height: 58rpx;
                }
            }            
        }
        .sport_safe_content_bottom{
            display: flex;
            align-items: center;
            padding-top: 20rpx;
            box-sizing: border-box;
            .sport_safe_content_bottom_item{
                display: flex;
                align-items: center;
                margin-right: 30rpx;
                &:last-child{
                    margin-right: 0;
                }
                .name{
                    font-weight: 400;
                    font-size: 24rpx;
                    color: #999999;
                }
                .value{
                    font-weight: 600;
                    font-size: 32rpx;
                    color: #333333;
                    line-height: 40rpx;
                    margin-left: 16rpx;
                }
            }
            
        }        
    }
    .social_health{
        position: relative;
        width: 702rpx;
        margin: 0 auto;
        margin-top: 36rpx;
        background: #FFFFFF;
        border-radius: 40rpx;
        padding: 28rpx 32rpx;
        box-sizing: border-box;
        .social_health_content_item_pic{
            position: absolute;
            right: 136rpx;
            top: 0;
            width: 248rpx;
            height: 178rpx;
        }
        .social_health_title{
            display: flex;
            align-items: center;
            justify-content: space-between;
            .social_health_title_text{
                font-weight: 600;
                font-size: 32rpx;
                color: #333333;
                line-height: 40rpx;
            }
            .title_icon{
                width: 48rpx;
                height: 48rpx;
            }
        }
        .social_health_content{
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding-top: 26rpx;
            box-sizing: border-box;
            .social_health_content_item{
                display: flex;
                align-items: center;
                .name{
                    font-weight: 400;
                    font-size: 48rpx;
                    color: #999999;
                    line-height: 40rpx;
                    margin-right: 20rpx;
                }
                .text{
                    font-weight: 600;
                    font-size: 40rpx;
                    color: #ABCD32;
                    line-height: 40rpx;
                }
            }
        }

    }
}
</style>